'''
列表生成式
'''
# range(start,end,step)
print(list(range(5)))
print(list(range(1,10)))
# 步长- 默认步长是1
print(list(range(1,10,2)))
print(list(range(0,100,2)))

print(list(range(100,0,-2)))
print(list(range(100,-100,-1)))

# [1,4,9,16,25,36]
r = []
for i in range(1,7):
    r.append(i*i)

# 列表生成式
r = [i*i for i in range(1,7)]
print(r)
r = [i**3 for i in range(1,7)]
print(r)

# 列表生成式中还可以添加条件
r = [i**3 for i in [1,2,3,4,5,6,7,8] if i%2==0]
print(r)

# 列表生成式中还可以使用双重循环
r = [i+j for i in 'ABC' for j in 'XYZ']
print(r)
